const express = require('express');
const {
   getUsers,
   getUser,
   updateUser,
   removeUser,
   updateAvatar,
   updateUsername,
   updateMainGroup,
} = require('../route-handlers/user');

// 操作单个用户
const userRouter = express.Router();
userRouter.route('/').get(getUser).patch(updateUser);
userRouter.route('/avatar').post(updateAvatar);
userRouter.route('/username').post(updateUsername);
userRouter.route('/maingroup').post(updateMainGroup);

// 管理员操作
const usersRouter = express.Router();
usersRouter.route('/').get(getUsers);
usersRouter.route('/:id').delete(removeUser);

module.exports = {
   userRouter,
   usersRouter,
};
